From 85fee3309260ef843f4533325cafa1e024c54631 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sat, 12 Nov 2011 05:38:52 +0100 Subject: [PATCH] a11y: Add a hash function for cell infos Note that comparing the tree is not necessary as the nodes are already unique per row. --- gtk/a11y/gtktreeviewaccessible.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/gtk/a11y/gtktreeviewaccessible.c b/gtk/a11y/gtktreeviewaccessible.c index 0680a946a9..ebab327e80 100644 --- a/gtk/a11y/gtktreeviewaccessible.c +++ b/gtk/a11y/gtktreeviewaccessible.c @@ -241,6 +241,28 @@ cell_info_get_path (GtkTreeViewAccessibleCellInfo *cell_info) cell_info->node); } +static guint +cell_info_hash (gconstpointer info) +{ + const GtkTreeViewAccessibleCellInfo *cell_info = info; + guint node, col; + + node = GPOINTER_TO_UINT (cell_info->node); + col = GPOINTER_TO_UINT (cell_info->cell_col_ref); + + return ((node << sizeof (guint) / 2) | (node >> sizeof (guint) / 2)) ^ col; +} + +static gboolean +cell_info_equal (gconstpointer a, gconstpointer b) +{ + const GtkTreeViewAccessibleCellInfo *cell_info_a = a; + const GtkTreeViewAccessibleCellInfo *cell_info_b = b; + + return cell_info_a->node == cell_info_b->node && + cell_info_a->cell_col_ref == cell_info_b->cell_col_ref; +} + static void gtk_tree_view_accessible_initialize (AtkObject *obj, gpointer data) @@ -263,8 +285,8 @@ gtk_tree_view_accessible_initialize (AtkObject *obj, accessible->idle_expand_path = NULL; accessible->n_children_deleted = 0; - accessible->cell_infos = g_hash_table_new_full (g_direct_hash, - g_direct_equal, NULL, (GDestroyNotify) cell_info_free); + accessible->cell_infos = g_hash_table_new_full (cell_info_hash, + cell_info_equal, NULL, (GDestroyNotify) cell_info_free); widget = GTK_WIDGET (data); tree_view = GTK_TREE_VIEW (widget); -- 2.30.2